package com.ln.cmsln.controller.zlxl;


import com.alibaba.fastjson.JSON;
import com.ln.cmsln.mapper.CourseserviceMapper;
import com.ln.cmsln.pojo.entity.Courseservice;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wuwenzhe
 * @since 2022-03-31
 */
@CrossOrigin//跨域
@RestController
@RequestMapping("/courseservice")
public class CourseserviceController {
    @Resource
    private CourseserviceMapper courseserviceMapper;

    @RequestMapping("getAllA")
    public String getAllA(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByA();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json;
    }

    @RequestMapping("getAllB")
    public String getAllB(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByB();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        return json;
    }

    @RequestMapping("getAllC")
    public String getAllC(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByC();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json;
    }

    @RequestMapping("getAllD")
    public String getAllD(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByD();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json;
    }

    @RequestMapping("getAllE")
    public String getAllE(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByE();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json;
    }

    @RequestMapping("getAllF")
    public String getAllF(Integer page, Integer limit) {
//        PageHelper.startPage(page, limit);
        List<Courseservice> courseservices = courseserviceMapper.selectAllByF();
        int count = courseservices.size();

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", courseservices);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json;
    }
}

